﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/List.Master" AutoEventWireup="true" CodeBehind="Sys_Config_User_List.aspx.cs" Inherits="Honestysoft.Baseframework.WebUI.SystemManage.Init.Sys_Config_User_List" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script language="javascript" type="text/javascript">
        jQuery.extend({
            //转换为json 字符串
            toJSON: function (object) {
                var type = typeof object;
                if ('object' == type) {
                    if (Array == object.constructor)
                        type = 'array';
                    else if (RegExp == object.constructor)
                        type = 'regexp';
                    else
                        type = 'object';
                }
                switch (type) {
                    case 'undefined':
                    case 'unknown':
                        return;
                        break;
                    case 'function':
                    case 'boolean':
                    case 'regexp':
                        return object.toString();
                        break;
                    case 'number':
                        return isFinite(object) ? object.toString() : 'null';
                        break;
                    case 'string':
                        return '"' + object.replace(/(\\|\")/g, "\\$1").replace(/\n|\r|\t/g,
               function () {
                   var a = arguments[0];
                   return (a == '\n') ? '\\n' :
                               (a == '\r') ? '\\r' :
                               (a == '\t') ? '\\t' : ""
               }) + '"';
                        break;
                    case 'object':
                        if (object === null) return 'null';
                        var results = [];
                        for (var property in object) {
                            var value = jQuery.toJSON(object[property]);
                            if (value !== undefined)
                                results.push(jQuery.toJSON(property) + ':' + value);
                        }
                        return '{' + results.join(',') + '}';
                        break;
                    case 'array':
                        var results = [];
                        for (var i = 0; i < object.length; i++) {
                            var value = jQuery.toJSON(object[i]);
                            if (value !== undefined) results.push(value);
                        }
                        return '[' + results.join(',') + ']';
                        break;
                }
            },
            //转换为json 对象

            evalJSON: function (strJson) {
                return eval("(" + strJson + ")");
            }

        });
        function setValue(value,key) {
            var lsb = document.getElementById("<%=lsbKeyValue.ClientID %>");
            var length = lsb.options.length;
            for (var i = 0; i < length; i++) {
                if (lsb.options[i].value == key) {                    
                    lsb.options[i].text = value;
                    return;
                }
            }            
            lsb.add(document.createElement("OPTION"));
            lsb.options[lsb.options.length - 1].text = value;
            lsb.options[lsb.options.length - 1].value = key;
        }
        function save() {
            var lsb = document.getElementById("<%=lsbKeyValue.ClientID %>");
            if (lsb.options.length == 0) {
                alert("没有需要保存的数据！");
                return;
            }
            var jsonData = [];
            var item;
            var dataStr = "";
            for (var i = 0; i < lsb.options.length; i++) {
                item = { "ID": lsb.options[i].value, "Value": lsb.options[i].text };
                jsonData.push(item);
            }

            $.ajax({
                type: "POST",
                url: "JSON/Init.ashx",
                data: { "kvJson": $.toJSON(jsonData) },
                success: function (msg) {
                    if (msg == "1") {
                        alert("保存成功！");
                    }
                    else {
                        alert("保存失败！");
                    }
                }
            });
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="query_area">
		名称：<asp:TextBox ID="txtName" runat="server"  cssClass="input2" MaxLength="200"></asp:TextBox>&nbsp;&nbsp;
		值：<asp:TextBox ID="txtValue" runat="server"  cssClass="input2" MaxLength="200"></asp:TextBox>&nbsp;&nbsp;
        <asp:Button runat="server" ID="btnQuery" Text="查 找" CssClass="btn_normal" 
			onMouseOver="this.className='btn_active'" 
            onMouseOut="this.className='btn_normal'" OnClick="btnQuery_Click" />
    </div>     
     <div class="button_area">
        <asp:Button runat="server" ID="btnSave" CssClass="btn_normal" 
			onMouseOver="this.className='btn_active'" 
            onMouseOut="this.className='btn_normal'" Text="保 存" OnClientClick="save();return false;" />
    </div>
            
    <table cellpadding="0" width="100%" cellspacing="0" border="1" class="t1" id="tGrid">
		<thead>  
            <th align="center" width="120">名称</th>
            <th align="center" width="180">值</th>
            <th align="center">说明</th>
            <th align="center" width="60">排序号</th>
      	</thead>           
		<asp:Repeater runat="server" ID="rptList" 
            onitemdatabound="rptList_ItemDataBound">
			<ItemTemplate>
				<tr>
					<td><%#  DataBinder.Eval(Container.DataItem,"Name") %></td>
					<td><asp:TextBox ID="txtValue" runat="server" Width="170px"></asp:TextBox></td>
                    <td><%#  DataBinder.Eval(Container.DataItem,"Description") %></td>
					<td><%#  DataBinder.Eval(Container.DataItem,"SortCode") %></td>
				</tr>  
			</ItemTemplate>
		</asp:Repeater>
        <tr>
            <td colspan="4" style="line-height: 28px;text-align:left;">
                <frameworkwebcontrols:aspnetpager id="AspNetPager1" runat="server"
                    alwaysshow="true" firstpagetext="首页" lastpagetext="尾页" nextpagetext="下一页" pageindexboxtype="DropDownList"
                    prevpagetext="上一页" showpageindex="true" showcustominfosection="Right" submitbuttontext="Go"
                    textafterpageindexbox="页" textbeforepageindexbox="转到" currentpagebuttonposition="End"
                    layouttype="Div" custominfotextalign="Right" custominfohtml="共%RecordCount%条记录。第%CurrentPageIndex%页，共%PageCount%页，每页%PageSize%条"
                    direction="LeftToRight" onpagechanged="AspNetPager1_PageChanged">
                </frameworkwebcontrols:aspnetpager>            
            </td>
        </tr>
    </table>
    <asp:ListBox ID="lsbKeyValue"  runat="server" style="display:none" SelectionMode=Multiple>
    </asp:ListBox>
</asp:Content>
